#include <stdlib.h>
#include <stdio.h>

#ifndef __DLX_H
#define __DLX_H

typedef struct Node_S
{
  struct Node_S * U;
  struct Node_S * D;
  struct Node_S * L;
  struct Node_S * R;
  int row, column, size;
} Node_T;
typedef Node_T * Node;

typedef struct SparseMatrix_S
{
  Node   root;
  Node_T columnHead[4*GRID_SIZE*GRID_SIZE];
  Node   rowHead[GRID_SIZE*GRID_SIZE*GRID_SIZE];
  Node_T cells[4*GRID_SIZE*GRID_SIZE*GRID_SIZE];
} SparseMatrix_T;
typedef SparseMatrix_T * SparseMatrix;

void removeCell(Node c);
void insertCell(Node c);
inline int candidateToRow (int candidate, int row, int column);
static void appendColumn (Node c, Node n);
SparseMatrix newSparseMatrix(void);
void delSparseMatrix(SparseMatrix sm);

#endif
